# Maintainer: fauxpark <fauxpark@gmail.com>

_realname=hid_bootloader_cli
pkgbase=mingw-w64-${_realname//_/-}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname//_/-}
pkgver=210130
pkgrel=1
pkgdesc='LUFA HID Bootloader CLI (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('GPL3')
url='https://github.com/abcminiuser/lufa'
depends=("${MINGW_PACKAGE_PREFIX}-libusb-compat")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
source=(
    "https://github.com/abcminiuser/lufa/archive/refs/tags/LUFA-${pkgver}.tar.gz"
    "01-libusb-compat-header.patch"
)
sha256sums=(
    '9b56921d59a50099cc6a8026248380a10ff518c8d02b547d6e617f71e6038f57'
    'e50e36fa4dc5a60a3c0235e66a5e35bbe6eddaf902975e2962fa8ddfbfa0f485'
)

prepare() {
    cd ${srcdir}/lufa-LUFA-${pkgver}/Bootloaders/HID/HostLoaderApp

    patch -p1 -i ${srcdir}/01-libusb-compat-header.patch
}

build() {
    cd ${srcdir}/lufa-LUFA-${pkgver}/Bootloaders/HID/HostLoaderApp

    OS=LINUX make hid_bootloader_cli
}

package() {
    cd ${srcdir}/lufa-LUFA-${pkgver}/Bootloaders/HID/HostLoaderApp

    install -Dm755 hid_bootloader_cli ${pkgdir}${MINGW_PREFIX}/bin/hid_bootloader_cli
}
